package logic

import (
	"context"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodCreateSKULogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodCreateSKULogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodCreateSKULogic {
	return &GoodCreateSKULogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品配置添加
func (l *GoodCreateSKULogic) GoodCreateSKU(in *homepage.GoodCreateSKURequest) (*homepage.GoodCreateSKUResponse, error) {
	//添加商品SDK入库
	goodSKU, err := dao.GoodCreateSKU(in)
	if err != nil {
		pkg.Warn("商品SDK添加失败")
		return nil, err
	}
	pkg.Warn("商品SDK添加成功")
	return &homepage.GoodCreateSKUResponse{
		Id: uint64(goodSKU),
	}, nil
}
